from threading import Thread
import time


# 第二种方式创建多线程
class EatThread(Thread):
    """ 写一个自定义的类，继承Thread """

    def __init__(self, name):
        super().__init__()  # 注意：必须要有这句话
        self.name = name

    def run(self):  # 必须要重写Process的run函数
        for i in range(6):
            print(f'进程{self.name}:正在吃饭。。。')
            time.sleep(0.3)


class WorkThread(Thread):
    """ 写一个自定义的类，继承Thread """

    def __init__(self, name):
        super().__init__()  # 注意：必须要有这句话
        self.name = name

    def run(self):  # 必须要重写Process的run函数
        for i in range(6):
            print(f'进程{self.name}:正在做作业。。。')
            time.sleep(0.3)


if __name__ == '__main__':
    t1 = EatThread('Thread-01')
    t2 = WorkThread('Thread-02')

    t1.start()
    t2.start()
